/*
 * @lc app=leetcode.cn id=1266 lang=javascript
 *
 * [1266] 访问所有点的最小时间
 */

// @lc code=start
/**
 * @param {number[][]} points
 * @return {number}
 */
var minTimeToVisitAllPoints = function (points) {
  return points
    .map(([x, y], index) => {
      if (index === 0) return 0;
      const [x0, y0] = points[index - 1];
      return Math.max(Math.abs(y - y0), Math.abs(x - x0))
    })
    .reduce((pre, cur) => pre + cur);
};
// @lc code=end

